﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using WMSADBUtility;

namespace WMSABL
{
    public class PublicDataSet_SAP
    {
        #region  SAP___Method
        /// <summary>
        /// SAP数据库连接
        /// </summary>
        public bool OpenSQL()
        {
            return DbHelperSAP.OpenSQL();
        }
        /// <summary>
        /// 是否存在该记录(SAP 库存表名)需赋予查询语句
        /// </summary>
        public bool SAP_PostionQuantityByPostionCode(string Position_Code)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(" SELECT TOP 1 Quantity FROM PD_Stock  WHERE Position_Code='" + Position_Code + "'");
            DataSet ds = new DataSet();
            ds = DbHelperSAP.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["Quantity"].ToString() != "0")
            {
                return true;
            }
            return false;
        }

        public DataSet GetDataSet(string strSql)
        {
            return DbHelperSAP.Query(strSql);
        }

        /// <summary>
        /// 设计变更表状态:(SAP 拣货单表名)需赋予查询语句
        /// </summary>
        public bool SAP_PostionQuantityByDH(string Position_Code)
        {
            DataSet ds = new DataSet();
            StringBuilder strSql = new StringBuilder();
            strSql.Append(" SELECT TOP 1 Quantity FROM PD_Stock  WHERE Position_Code='" + Position_Code + "'");
            ds = DbHelperSAP.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["Quantity"].ToString() != "0")
            {
                return true;
            }
            return false;
        }
        /// <summary>
        /// 更新一条数据 (SAP 库存表名)需赋予查询语句
        /// </summary>
        public bool Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update PD_Position set ");
            strSql.Append("Warehouse_Code='xxx',");
            strSql.Append("Warehouse_Code='xxx',");
            strSql.Append("Warehouse_Code='xxx',");
            strSql.Append("Warehouse_Code='xxx',");
            strSql.Append(" where NID=1 ");
            int rowsAffected = DbHelperSAP.ExecuteSql(strSql.ToString());
            if (rowsAffected > 0)
            {
                return true;
            }
            return false;
        }
        #endregion  MethodEx
    }
}
